#include "ant_queen.hh"


Queen::Queen (int x, int y):
  Ants ()
{
  pos_.first = x;
  pos_.second = y;
  tab_.push_back (FOOD);
  tab_.push_back (FIGHTER);
}

Queen::Queen (int x, int y, Team* t):
  Ants ()
{
  pos_.first = x;
  pos_.second = y;
  team_ = t;
  tab_.push_back (FOOD);
  tab_.push_back (FIGHTER);
}

Queen::~Queen ()
{
}

void
Queen::get_next_step ()
{
  make_ant ();
}

void
Queen::make_ant ()
{
  int retry = 0;
  std::pair<int, int> *c;
  Map *m = Map::instance ();
  Case cell;
  e_ant type;
  std::string name;

  if (food_ > 4)
  {
    for (retry = 0; retry < 10; retry++)
    {
      c = get_rand_case ();
      cell = m->get_case (c->second, c->first);
      if (cell.is_empty ()) // et sup egal a l'interet
      {
	type = tab_.front ();
	if (type == FOOD)
	  name = "food_worker";
	else if (type == FIGHTER)
	  name = "fighter";
	else if (type == WATER)
	  name = "water_worker";
	tab_.pop_front ();
	m->add_ant (c->first, c->second,
		    team_->add_ant(name, c->first, c->second));
	tab_.push_back (type);
	food_ -= 5;
      }
    }
  }
}

void
Queen::print ()
{
  if (food_ > 0)
    std::cout << P_QUEEN_ANT;
  else
    std::cout << P_QUEEN_ANT_EMPTY;
}
